package cn.factorybox.common.utils.resultUtils;

/**
 * @author flypig
 * @version 1.0
 * @date 2020-03-15 15:28
 */
public class MatrixCalculate {

    public static double[][] matrixMultiply(double[][] a,double[][] b) {
        if (a == null || b == null) {
            System.out.println("数组不能为空");
            return null;
        }
        double[][] matrix = null;
        int arows = a[0].length; // 列
        int bcolumn = b.length;  // 行
        if (arows == bcolumn) {
            matrix = new double[a.length][b[0].length];
//            System.out.println("长度：" + matrix[0].length);
            for (int i = 0; i < a.length; i++) {
                for (int j = 0; j < b[0].length; j++) {
                    for (int k = 0; k < b.length; k++) {
                        matrix[i][j] += a[i][k] * b[k][j];
                    }
                }
            }
        } else {
            System.out.println("数据有误");
        }
        return matrix;
    }
}
